package cn.liuhuan1.blogsModel.controller;

import cn.liuhuan1.entity.PageResult;
import cn.liuhuan1.entity.ReturnResult;
import cn.liuhuan1.webModelBean.api.FriendImp;
import cn.liuhuan1.webModelBean.bo.ArticleBo;
import cn.liuhuan1.webModelBean.bo.FriendBo;
import cn.liuhuan1.webModelBean.vo.ArticleVo;
import cn.liuhuan1.webModelBean.vo.FriendVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @Auther: liuhuan
 * @Date: 2021/2/22 - 02 - 22 - 15:42
 * @Description:
 * @version: 1.0
 */
@Controller
@RequestMapping("/friend")
public class FriendController {
    @Autowired
    private FriendImp friendImp;


    @RequestMapping(value = "/getFriend",method = RequestMethod.GET)
    @ResponseBody
    public ReturnResult getFriend(){
        List<FriendVo> getFriend = friendImp.getFriend();
        return ReturnResult.succes(getFriend);
    }

    @RequestMapping(value = "/getPageFriend",method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult getPageFriend(@RequestBody FriendBo friendBo){
        PageResult<FriendVo> pageResult =  friendImp.getPageFriend(friendBo);
        return ReturnResult.succes(pageResult);
    }

    @RequestMapping(value = "/getFriendById",method = RequestMethod.GET)
    @ResponseBody
    public ReturnResult getFriendById(@RequestParam("id") String id){
        FriendVo friendVo = friendImp.getFriendById(id);
        return ReturnResult.succes(friendVo);
    }

    @RequestMapping(value = "/saveFriend",method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult saveFriend(@RequestBody FriendBo friendBo){
        friendImp.saveFriend(friendBo);
        return ReturnResult.succes();
    }

    @RequestMapping(value = "/updateFriend", method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult updateFriend(@RequestBody FriendBo friendBo){
        friendImp.updateFriend(friendBo);
        return ReturnResult.succes();
    }

    @RequestMapping(value = "/delFriend",method = RequestMethod.POST)
    @ResponseBody
    public ReturnResult delFriend(@RequestParam("id") String id){
        friendImp.delFriend(id);
        return ReturnResult.succes();
    }


    @RequestMapping(value = "/updateStatus",method = RequestMethod.GET)
    @ResponseBody
    public ReturnResult updateStatus(@RequestParam("id") String id,@RequestParam("status") Integer status){
        friendImp.updateStatus(id,status);
        return ReturnResult.succes();
    }



}
